﻿@namespace BlazorComponent
@inherits BItemGroup

<BCascadingValue Value="this" IsFixed>
    <CascadingValue Value="Value?.ToString()" Name="WindowValue">
        <CascadingValue Value="IsDark" Name="IsDark">
            <div class="@CssProvider.GetClass()" style="@CssProvider.GetStyle()" id="@Id" @ref="Ref">
                <div class="@CssProvider.GetClass("container")" style="@CssProvider.GetStyle("container")">
                    @ChildContent

                    @if (ArrowsVisible)
                    {
                        var prevIcon = RTL ? NextIcon : PrevIcon;
                        var nextIcon = RTL ? PrevIcon : NextIcon;
                        
                        if (HasPrev)
                        {
                            <div class="@CssProvider.GetClass("prev")">
                                @if (PrevContent != null)
                                {
                                    @PrevContent(Prev)
                                }
                                else
                                {
                                    <BButton Icon @onclick="Prev" @attributes="GetAttributes(typeof(BButton))">
                                        <BIcon @attributes="GetAttributes(typeof(BIcon))">
                                            @prevIcon
                                        </BIcon>
                                    </BButton>
                                }
                            </div>
                        }

                        if (HasNext)
                        {
                            <div class="@CssProvider.GetClass("next")">
                                @if (NextContent != null)
                                {
                                    @NextContent(Next)
                                }
                                else
                                {
                                    <BButton Icon @onclick="Next" @attributes="GetAttributes(typeof(BButton))">
                                        <BIcon @attributes="GetAttributes(typeof(BIcon))">
                                            @nextIcon
                                        </BIcon>
                                    </BButton>
                                }
                            </div>
                        }
                    }
                </div>
                @RenderPart(typeof(BCarouselDelimiters<>))
                @RenderPart(typeof(BCarouselProgress<>))
            </div>
        </CascadingValue>
    </CascadingValue>
</BCascadingValue>
